<?php
// 导航配置文件 - 支持多个页面的导航系统

// 项目配置
// 基础配置模板
$base_config = [
    'project_name' => '后台管理系统后台管理系统后台管理系统后台管理系统',
    'navigation_data' => [
        [
            'first_menu' => '系统管理',
            'icon_class' => 'fa-cogs',
            'children' => [
                ['page_name' => '用户管理', 'publish_url' => '?p_id=user_manage'],
                ['page_name' => '角色管理', 'publish_url' => '?p_id=role_manage'],
                ['page_name' => '权限设置', 'publish_url' => '?p_id=permission_setting']
            ]
        ],
        [
            'first_menu' => '内容管理',
            'icon_class' => 'fa-file-text',
            'children' => [
                ['page_name' => '文章管理', 'publish_url' => '?p_id=article_manage'],
                ['page_name' => '分类管理', 'publish_url' => '?p_id=category_manage'],
                ['page_name' => '标签管理', 'publish_url' => '?p_id=tag_manage']
            ]
        ],
        [
            'first_menu' => '数据统计',
            'icon_class' => 'fa-chart-bar',
            'children' => [
                ['page_name' => '访问统计', 'publish_url' => '?p_id=visit_stats'],
                ['page_name' => '用户统计', 'publish_url' => '?p_id=user_stats']
            ]
        ]
    ]
];

// 所有项目都使用相同的配置
$project_configs = [
    '1' => $base_config,
    '2' => $base_config,
    '3' => $base_config,
    '4' => $base_config,
    '5' => $base_config,
    '6' => $base_config,
    '7' => $base_config,
    '8' => $base_config
];

// 生成导航菜单HTML的通用函数
function generateNavigation($navigation_data, $current_p_id) {
    $nav_html = '';
    
    foreach ($navigation_data as $menu) {
        // 检查当前菜单是否包含选中的子菜单
        $menu_active = false;
        foreach ($menu['children'] as $child) {
            if ($current_p_id && strpos($child['publish_url'], $current_p_id) !== false) {
                $menu_active = true;
                break;
            }
        }
        
        $menu_class = $menu_active ? 'nav-tab nav-ul a_active nav-show' : 'nav-tab nav-ul';
        
        $nav_html .= '<li class="' . $menu_class . '">' . "\n";
        $nav_html .= '    <a class="li-a" target="iframe"><i class="fa ' . $menu['icon_class'] . '"></i> ' . '<div class="nav-tab-text">' . $menu['first_menu'] . '</div>' . "\n";
        $nav_html .= '        <i class="my-icon lsm-sidebar-more"></i></a>' . "\n";
        $nav_html .= '    <div class="nav-box">' . "\n";
        
        foreach ($menu['children'] as $child) {
            // 检查是否为当前选中的菜单项
            $active_class = '';
            if ($current_p_id && strpos($child['publish_url'], $current_p_id) !== false) {
                $active_class = 'active';
            }
            
            $nav_html .= '        <a class="li-a-a ' . $active_class . '" href="' . $child['publish_url'] . '" target="iframe">' . $child['page_name'] . '</a>' . "\n";
        }
        
        $nav_html .= '    </div>' . "\n";
        $nav_html .= '</li>' . "\n";
    }
    
    return $nav_html;
}

// 获取指定页面的配置
function getPageConfig($page_number) {
    global $project_configs;
    return isset($project_configs[$page_number]) ? $project_configs[$page_number] : $project_configs['1'];
}
?>